home *** CD-ROM | disk | FTP | other *** search
Wrap
lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) NNNNAAAAMMMMEEEE listbox - Create and manipulate listbox widgets SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS lllliiiissssttttbbbbooooxxxx _p_a_t_h_N_a_m_e ?_o_p_t_i_o_n_s? SSSSTTTTAAAANNNNDDDDAAAARRRRDDDD OOOOPPPPTTTTIIIIOOOONNNNSSSS bbbbaaaacccckkkkggggrrrroooouuuunnnndddd ffffoooonnnntttt rrrreeeelllliiiieeeeffff ttttaaaakkkkeeeeFFFFooooccccuuuussss | bbbboooorrrrddddeeeerrrrWWWWiiiiddddtttthhhh hhhheeeeiiiigggghhhhtttt sssseeeelllleeeeccccttttBBBBaaaacccckkkkggggrrrroooouuuunnnndddd wwwwiiiiddddtttthhhh | ccccuuuurrrrssssoooorrrr hhhhiiiigggghhhhlllliiiigggghhhhttttBBBBaaaacccckkkkggggrrrroooouuuunnnndddd sssseeeelllleeeeccccttttBBBBoooorrrrddddeeeerrrrWWWWiiiiddddtttthhhh xxxxSSSSccccrrrroooollllllllCCCCoooommmmmmmmaaaannnndddd | eeeexxxxppppoooorrrrttttSSSSeeeelllleeeeccccttttiiiioooonnnn hhhhiiiigggghhhhlllliiiigggghhhhttttCCCCoooolllloooorrrr sssseeeelllleeeeccccttttFFFFoooorrrreeeeggggrrrroooouuuunnnndddd yyyySSSSccccrrrroooollllllllCCCCoooommmmmmmmaaaannnndddd | ffffoooorrrreeeeggggrrrroooouuuunnnndddd hhhhiiiigggghhhhlllliiiigggghhhhttttTTTThhhhiiiicccckkkknnnneeeessssssss sssseeeettttGGGGrrrriiiidddd See the ``options'' manual entry for details on the standard options. WWWWIIIIDDDDGGGGEEEETTTT----SSSSPPPPEEEECCCCIIIIFFFFIIIICCCC OOOOPPPPTTTTIIIIOOOONNNNSSSS Name: hhhheeeeiiiigggghhhhtttt Class: HHHHeeeeiiiigggghhhhtttt Command-Line Switch:----hhhheeeeiiiigggghhhhtttt Specifies the desired height for the window, in lines. If zero or | less, then the desired height for the window is made just large | enough to hold all the elements in the listbox. Name: sssseeeelllleeeeccccttttMMMMooooddddeeee | Class: SSSSeeeelllleeeeccccttttMMMMooooddddeeee | Command-Line Switch:----sssseeeelllleeeeccccttttmmmmooooddddeeee | Specifies one of several styles for manipulating the selection. The| value of the option may be arbitrary, but the default bindings | expect it to be either ssssiiiinnnngggglllleeee, bbbbrrrroooowwwwsssseeee, mmmmuuuullllttttiiiipppplllleeee, or eeeexxxxtttteeeennnnddddeeeedddd; the | default value is bbbbrrrroooowwwwsssseeee. Name: wwwwiiiiddddtttthhhh Class: WWWWiiiiddddtttthhhh Command-Line Switch:----wwwwiiiiddddtttthhhh Specifies the desired width for the window in characters. If the font doesn't have a uniform width then the width of the character ``0'' is used in translating from character units to screen units. | If zero or less, then the desired width for the window is made just | large enough to hold all the elements in the listbox. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN The lllliiiissssttttbbbbooooxxxx command creates a new window (given by the _p_a_t_h_N_a_m_e argument) and makes it into a listbox widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the listbox such as its colors, font, text, and relief. The lllliiiissssttttbbbbooooxxxx command returns its _p_a_t_h_N_a_m_e argument. At the time this command is invoked, there must not exist a window named _p_a_t_h_N_a_m_e, but _p_a_t_h_N_a_m_e's parent must exist. PPPPaaaaggggeeee 1111 lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) A listbox is a widget that displays a list of strings, one per line. When first created, a new listbox has no elements. Elements may be added or deleted using widget commands described below. In addition, one or more elements may be selected as described below. If a listbox is exporting its selection (see eeeexxxxppppoooorrrrttttSSSSeeeelllleeeeccccttttiiiioooonnnn option), then it will observe the standard X11 protocols for handling the selection. Listbox selections are available as type SSSSTTTTRRRRIIIINNNNGGGG; the value of the selection will | be the text of the selected elements, with newlines separating the | elements. | It is not necessary for all the elements to be displayed in the listbox | window at once; commands described below may be used to change the view | in the window. Listboxes allow scrolling in both directions using the | standard xxxxSSSSccccrrrroooollllllllCCCCoooommmmmmmmaaaannnndddd and yyyySSSSccccrrrroooollllllllCCCCoooommmmmmmmaaaannnndddd options. They also support | scanning, as described below. | IIIINNNNDDDDIIIICCCCEEEESSSS |||| Many of the widget commands for listboxes take one or more indices as | arguments. An index specifies a particular element of the listbox, in | any of the following ways: _n_u_m_b_e_r Specifies the element as a numerical index, where 0 corresponds to the first element in the listbox. aaaaccccttttiiiivvvveeee Indicates the element that has the location cursor. This | element will be displayed with an underline when the listbox | has the keyboard focus, and it is specified with the aaaaccccttttiiiivvvvaaaatttteeee| widget command. aaaannnncccchhhhoooorrrr Indicates the anchor point for the selection, which is set | with the sssseeeelllleeeeccccttttiiiioooonnnn aaaannnncccchhhhoooorrrr widget command. eeeennnndddd Indicates the end of the listbox. For some commands this means just after the last element; for other commands it means the last element. @@@@_x,,,,_y Indicates the element that covers the point in the listbox | window specified by _x and _y (in pixel coordinates). If no | element covers that point, then the closest element to that | point is used. | In the widget command descriptions below, arguments named _i_n_d_e_x, _f_i_r_s_t, | and _l_a_s_t always contain text indices in one of the above forms. WWWWIIIIDDDDGGGGEEEETTTT CCCCOOOOMMMMMMMMAAAANNNNDDDD The lllliiiissssttttbbbbooooxxxx command creates a new Tcl command whose name is _p_a_t_h_N_a_m_e. This command may be used to invoke various operations on the widget. It has the following general form: _p_a_t_h_N_a_m_e _o_p_t_i_o_n ?_a_r_g _a_r_g ...? PPPPaaaaggggeeee 2222 lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) _O_p_t_i_o_n and the _a_r_gs determine the exact behavior of the command. The following commands are possible for listbox widgets: _p_a_t_h_N_a_m_e aaaaccccttttiiiivvvvaaaatttteeee _i_n_d_e_x Sets the active element to the one indicated by _i_n_d_e_x. The active | element is drawn with an underline when the widget has the input | focus, and its index may be retrieved with the index aaaaccccttttiiiivvvveeee. _p_a_t_h_N_a_m_e bbbbbbbbooooxxxx _i_n_d_e_x Returns a list of four numbers describing the bounding box of the | text in the element given by _i_n_d_e_x. The first two elements of the | list give the x and y coordinates of the upper-left corner of the | screen area covered by the text (specified in pixels relative to the| widget) and the last two elements give the width and height of the | area, in pixels. If no part of the element given by _i_n_d_e_x is | visible on the screen then the result is an empty string; if the | element is partially visible, the result gives the full area of the | element, including any parts that are not visible. _p_a_t_h_N_a_m_e ccccggggeeeetttt _o_p_t_i_o_n Returns the current value of the configuration option given by | _o_p_t_i_o_n. _O_p_t_i_o_n may have any of the values accepted by the lllliiiissssttttbbbbooooxxxx | command. _p_a_t_h_N_a_m_e ccccoooonnnnffffiiiigggguuuurrrreeee ?_o_p_t_i_o_n? ?_v_a_l_u_e _o_p_t_i_o_n _v_a_l_u_e ...? Query or modify the configuration options of the widget. If no _o_p_t_i_o_n is specified, returns a list describing all of the available options for _p_a_t_h_N_a_m_e (see TTTTkkkk____CCCCoooonnnnffffiiiigggguuuurrrreeeeIIIInnnnffffoooo for information on the format of this list). If _o_p_t_i_o_n is specified with no _v_a_l_u_e, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no _o_p_t_i_o_n is specified). If one or more _o_p_t_i_o_n-_v_a_l_u_e pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. _O_p_t_i_o_n may have any of the values accepted by the lllliiiissssttttbbbbooooxxxx command. _p_a_t_h_N_a_m_e ccccuuuurrrrsssseeeelllleeeeccccttttiiiioooonnnn Returns a list containing the numerical indices of all of the elements in the listbox that are currently selected. If there are no elements selected in the listbox then an empty string is returned. _p_a_t_h_N_a_m_e ddddeeeelllleeeetttteeee _f_i_r_s_t ?_l_a_s_t? Deletes one or more elements of the listbox. _F_i_r_s_t and _l_a_s_t are indices specifying the first and last elements in the range to delete. If _l_a_s_t isn't specified it defaults to _f_i_r_s_t, i.e. a single element is deleted. _p_a_t_h_N_a_m_e ggggeeeetttt _f_i_r_s_t ?_l_a_s_t? If _l_a_s_t is omitted, returns the contents of the listbox element indicated by _f_i_r_s_t. If _l_a_s_t is specified, the command returns a | PPPPaaaaggggeeee 3333 lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) list whose elements are all of the listbox elements between _f_i_r_s_t | and _l_a_s_t, inclusive. Both _f_i_r_s_t and _l_a_s_t may have any of the | standard forms for indices. _p_a_t_h_N_a_m_e iiiinnnnddddeeeexxxx _i_n_d_e_x Returns a decimal string giving the integer index value that corresponds to _i_n_d_e_x. _p_a_t_h_N_a_m_e iiiinnnnsssseeeerrrrtttt _i_n_d_e_x ?_e_l_e_m_e_n_t _e_l_e_m_e_n_t ...? Inserts zero or more new elements in the list just before the | element given by _i_n_d_e_x. If _i_n_d_e_x is specified as eeeennnndddd then the new | elements are added to the end of the list. Returns an empty string. _p_a_t_h_N_a_m_e nnnneeeeaaaarrrreeeesssstttt _y Given a y-coordinate within the listbox window, this command returns the index of the (visible) listbox element nearest to that y- coordinate. _p_a_t_h_N_a_m_e ssssccccaaaannnn _o_p_t_i_o_n _a_r_g_s This command is used to implement scanning on listboxes. It has two forms, depending on _o_p_t_i_o_n: _p_a_t_h_N_a_m_e ssssccccaaaannnn mmmmaaaarrrrkkkk _x _y Records _x and _y and the current view in the listbox window; used in conjunction with later ssssccccaaaannnn ddddrrrraaaaggggttttoooo commands. Typically this command is associated with a mouse button press in the widget. It returns an empty string. _p_a_t_h_N_a_m_e ssssccccaaaannnn ddddrrrraaaaggggttttoooo _x _y. This command computes the difference between its _x and _y arguments and the _x and _y arguments to the last ssssccccaaaannnn mmmmaaaarrrrkkkk command for the widget. It then adjusts the view by 10 times the difference in coordinates. This command is typically associated with mouse motion events in the widget, to produce the effect of dragging the list at high speed through the window. The return value is an empty string. _p_a_t_h_N_a_m_e sssseeeeeeee _i_n_d_e_x Adjust the view in the listbox so that the element given by _i_n_d_e_x is| visible. If the element is already visible then the command has no | effect; if the element is near one edge of the window then the | listbox scrolls to bring the element into view at the edge; | otherwise the listbox scrolls to center the element. _p_a_t_h_N_a_m_e sssseeeelllleeeeccccttttiiiioooonnnn _o_p_t_i_o_n _a_r_g This command is used to adjust the selection within a listbox. It has several forms, depending on _o_p_t_i_o_n: _p_a_t_h_N_a_m_e sssseeeelllleeeeccccttttiiiioooonnnn aaaannnncccchhhhoooorrrr _i_n_d_e_x Sets the selection anchor to the element given by _i_n_d_e_x. The selection anchor is the end of the selection that is fixed while dragging out a selection with the mouse. The index PPPPaaaaggggeeee 4444 lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) aaaannnncccchhhhoooorrrr may be used to refer to the anchor element. _p_a_t_h_N_a_m_e sssseeeelllleeeeccccttttiiiioooonnnn cccclllleeeeaaaarrrr _f_i_r_s_t ?_l_a_s_t? If any of the elements between _f_i_r_s_t and _l_a_s_t (inclusive) are selected, they are deselected. The selection state is not changed for elements outside this range. _p_a_t_h_N_a_m_e sssseeeelllleeeeccccttttiiiioooonnnn iiiinnnncccclllluuuuddddeeeessss _i_n_d_e_x Returns 1 if the element indicated by _i_n_d_e_x is currently selected, 0 if it isn't. _p_a_t_h_N_a_m_e sssseeeelllleeeeccccttttiiiioooonnnn sssseeeetttt _f_i_r_s_t ?_l_a_s_t? Selects all of the elements in the range between _f_i_r_s_t and _l_a_s_t, inclusive, without affecting the selection state of elements outside that range. _p_a_t_h_N_a_m_e ssssiiiizzzzeeee Returns a decimal string indicating the total number of elements in the listbox. _p_a_t_h_N_a_m_e xxxxvvvviiiieeeewwww _a_r_g_s This command is used to query and change the horizontal position of the information in the widget's window. It can take any of the following forms: _p_a_t_h_N_a_m_e xxxxvvvviiiieeeewwww Returns a list containing two elements. Each element is a real fraction between 0 and 1; together they describe the horizontal span that is visible in the window. For example, if the first element is .2 and the second element is .6, 20% of the listbox's text is off-screen to the left, the middle 40% is visible in the window, and 40% of the text is off-screen to the right. These are the same values passed to scrollbars via the ----xxxxssssccccrrrroooollllllllccccoooommmmmmmmaaaannnndddd option. _p_a_t_h_N_a_m_e xxxxvvvviiiieeeewwww _i_n_d_e_x Adjusts the view in the window so that the character position given by _i_n_d_e_x is displayed at the left edge of the window. Character positions are defined by the width of the character 0000. _p_a_t_h_N_a_m_e xxxxvvvviiiieeeewwww mmmmoooovvvveeeettttoooo _f_r_a_c_t_i_o_n Adjusts the view in the window so that _f_r_a_c_t_i_o_n of the total width of the listbox text is off-screen to the left. _f_r_a_c_t_i_o_n must be a fraction between 0 and 1. _p_a_t_h_N_a_m_e xxxxvvvviiiieeeewwww ssssccccrrrroooollllllll _n_u_m_b_e_r _w_h_a_t This command shifts the view in the window left or right according to _n_u_m_b_e_r and _w_h_a_t. _N_u_m_b_e_r must be an integer. _W_h_a_t must be either uuuunnnniiiittttssss or ppppaaaaggggeeeessss or an abbreviation of one of these. If _w_h_a_t is uuuunnnniiiittttssss, the view adjusts left or right by _n_u_m_b_e_r character units (the width of the 0000 character) on the PPPPaaaaggggeeee 5555 lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) display; if it is ppppaaaaggggeeeessss then the view adjusts by _n_u_m_b_e_r screenfuls. If _n_u_m_b_e_r is negative then characters farther to the left become visible; if it is positive then characters farther to the right become visible. _p_a_t_h_N_a_m_e yyyyvvvviiiieeeewwww ?_a_r_g_s? This command is used to query and change the vertical position of the text in the widget's window. It can take any of the following forms: _p_a_t_h_N_a_m_e yyyyvvvviiiieeeewwww Returns a list containing two elements, both of which are real fractions between 0 and 1. The first element gives the position of the listbox element at the top of the window, relative to the listbox as a whole (0.5 means it is halfway through the listbox, for example). The second element gives the position of the listbox element just after the last one in the window, relative to the listbox as a whole. These are the same values passed to scrollbars via the ----yyyyssssccccrrrroooollllllllccccoooommmmmmmmaaaannnndddd option. _p_a_t_h_N_a_m_e yyyyvvvviiiieeeewwww _i_n_d_e_x Adjusts the view in the window so that the element given by _i_n_d_e_x is displayed at the top of the window. _p_a_t_h_N_a_m_e yyyyvvvviiiieeeewwww mmmmoooovvvveeeettttoooo _f_r_a_c_t_i_o_n Adjusts the view in the window so that the element given by _f_r_a_c_t_i_o_n appears at the top of the window. _F_r_a_c_t_i_o_n is a fraction between 0 and 1; 0 indicates the first element in the listbox, 0.33 indicates the element one-third the way through the listbox, and so on. _p_a_t_h_N_a_m_e yyyyvvvviiiieeeewwww ssssccccrrrroooollllllll _n_u_m_b_e_r _w_h_a_t This command adjusts the view in the window up or down according to _n_u_m_b_e_r and _w_h_a_t. _N_u_m_b_e_r must be an integer. _W_h_a_t must be either uuuunnnniiiittttssss or ppppaaaaggggeeeessss. If _w_h_a_t is uuuunnnniiiittttssss, the view adjusts up or down by _n_u_m_b_e_r lines; if it is ppppaaaaggggeeeessss then the view adjusts by _n_u_m_b_e_r screenfuls. If _n_u_m_b_e_r is negative then earlier elements become visible; if it is positive then later elements become visible. DDDDEEEEFFFFAAAAUUUULLLLTTTT BBBBIIIINNNNDDDDIIIINNNNGGGGSSSS Tk automatically creates class bindings for listboxes that give them Motif-like behavior. Much of the behavior of a listbox is determined by its sssseeeelllleeeeccccttttMMMMooooddddeeee option, which selects one of four ways of dealing with the selection. If the selection mode is ssssiiiinnnngggglllleeee or bbbbrrrroooowwwwsssseeee, at most one element can be selected in the listbox at once. In both modes, clicking button 1 on an element selects it and deselects any other selected item. In bbbbrrrroooowwwwsssseeee mode it is also possible to drag the selection with button 1. PPPPaaaaggggeeee 6666 lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) If the selection mode is mmmmuuuullllttttiiiipppplllleeee or eeeexxxxtttteeeennnnddddeeeedddd, any number of elements may be selected at once, including discontiguous ranges. In mmmmuuuullllttttiiiipppplllleeee mode, clicking button 1 on an element toggles its selection state without affecting any other elements. In eeeexxxxtttteeeennnnddddeeeedddd mode, pressing button 1 on an element selects it, deselects everything else, and sets the anchor to the element under the mouse; dragging the mouse with button 1 down extends the selection to include all the elements between the anchor and the element under the mouse, inclusive. Most people will probably want to use bbbbrrrroooowwwwsssseeee mode for single selections and eeeexxxxtttteeeennnnddddeeeedddd mode for multiple selections; the other modes appear to be useful only in special situations. In addition to the above behavior, the following additional behavior is | defined by the default bindings: [1] In eeeexxxxtttteeeennnnddddeeeedddd mode, the selected range can be adjusted by pressing button 1 with the Shift key down: this modifies the selection to consist of the elements between the anchor and the element under the mouse, inclusive. The un-anchored end of this new selection can also be dragged with the button down. [2] In eeeexxxxtttteeeennnnddddeeeedddd mode, pressing button 1 with the Control key down starts a toggle operation: the anchor is set to the element under the mouse, and its selection state is reversed. The selection state of other elements isn't changed. If the mouse is dragged with button 1 down, then the selection state of all elements between the anchor and the element under the mouse is set to match that of the anchor element; the selection state of all other elements remains what it was before the toggle operation began. [3] If the mouse leaves the listbox window with button 1 down, the window scrolls away from the mouse, making information visible that used to be off-screen on the side of the mouse. The scrolling continues until the mouse re-enters the window, the button is released, or the end of the listbox is reached. [4] Mouse button 2 may be used for scanning. If it is pressed and dragged over the listbox, the contents of the listbox drag at high speed in the direction the mouse moves. [5] If the Up or Down key is pressed, the location cursor (active element) moves up or down one element. If the selection mode is bbbbrrrroooowwwwsssseeee or eeeexxxxtttteeeennnnddddeeeedddd then the new active element is also selected and all other elements are deselected. In eeeexxxxtttteeeennnnddddeeeedddd mode the new active element becomes the selection anchor. [6] In eeeexxxxtttteeeennnnddddeeeedddd mode, Shift-Up and Shift-Down move the location cursor (active element) up or down one element and also extend the selection to that element in a fashion similar to dragging with mouse button 1. PPPPaaaaggggeeee 7777 lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) [7] The Left and Right keys scroll the listbox view left and right by the width of the character 0000. Control-Left and Control-Right scroll the listbox view left and right by the width of the window. Control-Prior and Control-Next also scroll left and right by the width of the window. [8] The Prior and Next keys scroll the listbox view up and down by one page (the height of the window). [9] The Home and End keys scroll the listbox horizontally to the left and right edges, respectively. [10] Control-Home sets the location cursor to the the first element in the listbox, selects that element, and deselects everything else in the listbox. [11] Control-End sets the location cursor to the the last element in the listbox, selects that element, and deselects everything else in the listbox. [12] In eeeexxxxtttteeeennnnddddeeeedddd mode, Control-Shift-Home extends the selection to the first element in the listbox and Control-Shift-End extends the selection to the last element. [13] In mmmmuuuullllttttiiiipppplllleeee mode, Control-Shift-Home moves the location cursor to the first element in the listbox and Control-Shift-End moves the location cursor to the last element. [14] The space and Select keys make a selection at the location cursor (active element) just as if mouse button 1 had been pressed over this element. [15] In eeeexxxxtttteeeennnnddddeeeedddd mode, Control-Shift-space and Shift-Select extend the selection to the active element just as if button 1 had been pressed with the Shift key down. [16] In eeeexxxxtttteeeennnnddddeeeedddd mode, the Escape key cancels the most recent selection and restores all the elements in the selected range to their previous selection state. [17] Control-slash selects everything in the widget, except in ssssiiiinnnngggglllleeee and bbbbrrrroooowwwwsssseeee modes, in which case it selects the active element and deselects everything else. [18] Control-backslash deselects everything in the widget, except in bbbbrrrroooowwwwsssseeee mode where it has no effect. [19] The F16 key (labelled Copy on many Sun workstations) or Meta-w copies the selection in the widget to the clipboard, if there is a selection. PPPPaaaaggggeeee 8888 lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) lllliiiissssttttbbbbooooxxxx((((3333TTTTkkkk)))) The behavior of listboxes can be changed by defining new bindings for individual widgets or by redefining the class bindings. KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS listbox, widget PPPPaaaaggggeeee 9999